package com.hy.erp.inventory.service;

import java.util.List ;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.IMembereRelationDao;
import com.hy.erp.inventory.pojo.MembereRelation;
import com.hy.erp.inventory.pojo.interfaces.IMembereRelation;
import com.hy.erp.inventory.service.interfaces.IMembereRelationService;

@ Name ( "membereRelationService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
public class MembereRelationService extends AbstractBusinessService < IMembereRelation > implements IMembereRelationService
{

	@ Override
	public boolean addMaterielType (
										IMembereRelation membereRelation )
	{




		if ( null == membereRelation )
		{
			return true ;
		}

		else
		{
			System.out
						.println ( "ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh" ) ;

			IMembereRelationDao membereRelationDao =
												( IMembereRelationDao ) this
																			.getDao ( IMembereRelation.class ) ;

			return membereRelationDao
									.persist ( membereRelation ) ;
		}

	
	
	
	}

	@ Override
	public boolean modifyMembereRelation (
											IMembereRelation membereRelation )
	{




		if ( ( null == membereRelation )
				|| ( null == membereRelation
											.getIdentifier ( ) )
				|| ( membereRelation
									.getIdentifier ( )
									.trim ( )
									.length ( ) == 0 ) )
		{
			return true ;
		}
		else
		{

			IMembereRelationDao membereRelationDao =
				( IMembereRelationDao ) this
											.getDao ( IMembereRelation.class ) ;


			if ( null == membereRelation )
			{
				throw new ArchitectureFoundationException (
															"修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}

			return ( membereRelationDao
									.merge ( membereRelation ) != null ) ;
		}

	
	
	
	}

	@ Override
	public Integer removeMembereRelation (
											String [ ] membereRelationIds )
	{

		if ( ( null == membereRelationIds )
				|| ( membereRelationIds.length == 0 ) )
		{
			return new Integer (
									0 ) ;
		}
		else
		{

			IMembereRelationDao membereRelationDao =
				( IMembereRelationDao ) this
											.getDao ( IMembereRelation.class ) ;

			return membereRelationDao
									.remove ( membereRelationIds ) ;
		}
	
	
	}

	@ Override
	public String [ ] addMaterielType (
										Object [ ] membereRelation )
	{
		if ( null == membereRelation )
		{
			return null ;
		}

		else
		{

			IMembereRelationDao membereRelationDao =
												( IMembereRelationDao ) this
																			.getDao ( IMembereRelation.class ) ;

			MembereRelation[] membereRelations=new MembereRelation[membereRelation.length];
						for(int i=0;i<membereRelation.length;i++)
						{
							MembereRelation membereRelation2=( MembereRelation ) membereRelation[i];
							membereRelations[i]=membereRelation2;
						}
						return membereRelationDao
						                .persist ( membereRelations ) ;
			
		}

	
	
	
	
	}

	@ Override
	public List < IMembereRelation > getAllMembereRelation ( )
	{
		IMembereRelationDao membereRelationDao =
			( IMembereRelationDao ) this
										.getDao ( IMembereRelation.class ) ;

		return membereRelationDao
								.find ( );
	}

	@ Override
	public String [ ] modifyMembereRelation (
												Object [ ] membereRelation )
	{

		if ( null == membereRelation )
		{
			return null ;
		}

		else
		{

			IMembereRelationDao membereRelationDao =
												( IMembereRelationDao ) this
																			.getDao ( IMembereRelation.class ) ;

			MembereRelation[] membereRelations=new MembereRelation[membereRelation.length];
						for(int i=0;i<membereRelation.length;i++)
						{
							MembereRelation membereRelation2=( MembereRelation ) membereRelation[i];
							membereRelations[i]=membereRelation2;
						}
						return membereRelationDao
						                .merge ( membereRelations ) ;
			
		}

	
	
	
	
	
	}

}
